import socketserver
import threading
import uvicorn as uvicorn

from FastApi.WebServer import fastapi_app
from Lib import Utils
from Lib.Server import server, TcpProtocol

if __name__ == '__main__':
    config = Utils.GetIniFile("./config.ini")
    tcp_server = socketserver.ThreadingTCPServer((server.host, server.port), TcpProtocol)
    threading.Thread(target=lambda: (uvicorn.run(app=fastapi_app, host=config.get("base", "host"),
                                                 port=int(config.get("base", "web_port")))), daemon=True).start()
    tcp_server.serve_forever()
